/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */#ifndef MOZILLA_GFX_IMAGEHOST_H#define MOZILLA_GFX_IMAGEHOST_H#include<stdio.h> // for FILE#include"CompositableHost.h" // for CompositableHost#include"mozilla/Attributes.h" // for override#include"mozilla/RefPtr.h" // for RefPtr#include"mozilla/gfx/MatrixFwd.h" // for Matrix4x4#include"mozilla/gfx/Point.h" // for Point#include"mozilla/gfx/Polygon.h" // for Polygon#include"mozilla/gfx/Rect.h" // for Rect#include"mozilla/gfx/Types.h" // for SamplingFilter#include"mozilla/layers/CompositorTypes.h" // for TextureInfo, etc#include"mozilla/layers/ImageComposite.h" // for ImageComposite#include"mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor#include"mozilla/layers/LayersTypes.h" // for LayerRenderState, etc#include"mozilla/layers/TextureHost.h" // for TextureHost, etc#include"mozilla/mozalloc.h" // for operator delete#include"nsCOMPtr.h" // for already_AddRefed#include"nsRect.h" // for mozilla::gfx::IntRect#include"nsRegionFwd.h" // for nsIntRegion#include"nscore.h" // for nsACStringnamespacemozilla{namespacelayers{classCompositor;structEffectChain;classHostLayerManager;/** * ImageHost. Works with ImageClientSingle and ImageClientBuffered */classImageHost:publicCompositableHost,publicImageComposite{public:explicitImageHost(constTextureInfo&aTextureInfo);~ImageHost();virtualCompositableTypeGetType()override{returnmTextureInfo.mCompositableType;}virtualImageHost*AsImageHost()override{returnthis;}virtualvoidComposite(Compositor*aCompositor,LayerComposite*aLayer,EffectChain&aEffectChain,floataOpacity,constgfx::Matrix4x4&aTransform,constgfx::SamplingFilteraSamplingFilter,constgfx::IntRect&aClipRect,constnsIntRegion*aVisibleRegion=nullptr,constMaybe<gfx::Polygon>&aGeometry=Nothing())override;virtualvoidUseTextureHost(constnsTArray<TimedTexture>&aTextures)override;virtualvoidRemoveTextureHost(TextureHost*aTexture)override;virtualTextureHost*GetAsTextureHost(gfx::IntRect*aPictureRect=nullptr)override;virtualvoidAttach(Layer*aLayer,TextureSourceProvider*aProvider,AttachFlagsaFlags=NO_FLAGS)override;virtualvoidSetTextureSourceProvider(TextureSourceProvider*aProvider)override;gfx::IntSizeGetImageSize()constoverride;virtualvoidPrintInfo(std::stringstream&aStream,constchar*aPrefix)override;virtualvoidDump(std::stringstream&aStream,constchar*aPrefix="",boolaDumpHtml=false)override;virtualalready_AddRefed<gfx::DataSourceSurface>GetAsSurface()override;virtualboolLock()override;virtualvoidUnlock()override;virtualalready_AddRefed<TexturedEffect>GenEffect(constgfx::SamplingFilteraSamplingFilter)override;voidSetCurrentTextureHost(TextureHost*aTexture);virtualvoidCleanupResources()override;boolIsOpaque();structRenderInfo{intimageIndex;TimedImage*img;RefPtr<TextureHost>host;RenderInfo():imageIndex(-1),img(nullptr){}};// Acquire rendering information for the current frame.boolPrepareToRender(TextureSourceProvider*aProvider,RenderInfo*aOutInfo);// Acquire the TextureSource for the currently prepared frame.RefPtr<TextureSource>AcquireTextureSource(constRenderInfo&aInfo);// Send ImageComposite notifications and update the ChooseImage bias.voidFinishRendering(constRenderInfo&aInfo);// This should only be called inside a lock, or during rendering. It is// infallible to enforce this.TextureHost*CurrentTextureHost()const{MOZ_ASSERT(mCurrentTextureHost);returnmCurrentTextureHost;}protected:// ImageCompositevirtualTimeStampGetCompositionTime()constoverride;// Use a simple RefPtr because the same texture is already held by a// a CompositableTextureHostRef in the array of TimedImage.// See the comment in CompositableTextureRef for more details.RefPtr<TextureHost>mCurrentTextureHost;CompositableTextureSourceRefmCurrentTextureSource;// When doing texture uploads it's best to alternate between two (or three)// texture sources so that the texture we upload to isn't being used by// the GPU to composite the previous frame.RefPtr<TextureSource>mExtraTextureSource;boolmLocked;};}// namespace layers}// namespace mozilla#endif